@extends('base')

@section('title',$product->ProName)

@section('content')
    <div hidden="hidden" id="proId">
        {{$product->ProId}}
        {{csrf_field()}}
    </div>

    <div style="text-align: center;padding-top: 10px">
        <img  class="bk_preview" src="{{Style}}/images/{{$product->ProPreview}}" alt="icon" >
    </div>


    <div class="weui_cells_title">
        <span class="bk_title">{{$product->ProName}}</span>
        <span class="bk_price" style="float: right">￥ {{$product->ProPrice}}</span>
    </div>

    <div class="weui_cells">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
                <p class="bk_summary" >{{$product->ProSummary}}</p>
            </div>

        </div>
    </div>

    <article class="weui_article">
        <h1>简介</h1>
        <section>
            <section>
                <p>{{$productMainInfo->PmiInfo}}</p>
            </section>

        </section>
    </article>
    <div>
        <button onclick="addCar()" class="weui_btn weui_btn_primary">加入购物车</button>
        <button id="num" class="weui_btn weui_btn_default">去结算(0)</button>
    </div>

@endsection


@section('js')

<script type="text/javascript">
    function addCar() {
        var postData = {
            'proId':$('#proId').html(),
            '_token':$('input[name=_token]').val()
        };
        $.post("{{url('Service/Car/addProduct')}}",postData,function () {
        },'JSON');

        var text = $('#num').html();

        var num = text.substring(text.indexOf('(')+1,text.indexOf('(')+2);
        num = parseInt(num,10);
        num+=1;
        text = text.substring(0,text.indexOf(')')-1);
        text+=(num+')');
        $('#num').html(text);
    }
</script>

@endsection
